package practicaspl.uno;

public class Front {
	private String to;
	private String date;
	private String where;
	private String why;
	
	public Front()
	{
		to = new String();
		date = new String();
		where = new String();
		why = new String();
	}
	public String getTo() {
		return to;
	}
	public void setTo(String to) {
		this.to = to;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public String getWhere() {
		return where;
	}
	public void setWhere(String where) {
		this.where = where;
	}
	public String getWhy() {
		return why;
	}
	public void setWhy(String why) {
		this.why = why;
	}
	
	public void leerfront(String f)
	{
		int princ = 0;
		int fin = 0;
		String t, d, whe, wh;
		//buscamos la parte del xml donde tenemos el to
		princ = f.indexOf("<to>");
		fin = f.indexOf("</to>");
		t = f.substring(princ, fin);
		setTo( t.replace("</to>", ""));
		//buscamos la parte del xml donde tenemos el date
		princ = f.indexOf("<date>");
		fin = f.indexOf("</date>");
		d = f.substring(princ, fin);
		setDate( d.replace("</date>", ""));
		//buscamos la parte del xml donde tenemos el where
		princ = f.indexOf("<where>");
		fin = f.indexOf("</where>");
		whe = f.substring(princ, fin);
		setWhere( whe.replace("</where>", ""));
		//buscamos la parte del xml donde tenemos el why
		princ = f.indexOf("<why>");
		fin = f.indexOf("</why>");
		wh = f.substring(princ, fin);
		setWhy( wh.replace("</why>", ""));
	}
	
	public String translatefront()
	{
		String tf;
		tf = "<TBODY>\n<TR><TD font class=\"front\">To: </TD>\n<TD><font color=\"green\">";
		tf = tf + getTo();
		tf = tf + "</font></TD></TR>\n<TR><TD class=\"front\">When: </TD>\n<TD><font color=\"yellow\">";
		tf = tf + getDate();
		tf =  tf + "</font></TD></TR>\n<TR><TD class=\"front\">Venue: </TD>\n<TD><font color=\"orange\">";
		tf = tf + getWhere();
		tf = tf + "</font></TD></TR>\n<TR><TD class=\"front\">Occasion: </TD>\n<TD><font color=\"purple\">";
		tf = tf + getWhy();
		tf = tf + "</font></TD></TR>\n</TBODY>\n</TABLE>\n";
		return (tf);
		
	}
	
}
